package cii_lib_graph;
/*TODO
 * Generate Configuration Map
 * 
 */


import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.VetoableChangeListener;
import java.io.File;

import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JTextPane;
import javax.swing.JTree;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
import javax.swing.border.BevelBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.SoftBevelBorder;
import javax.swing.border.TitledBorder;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeSelectionModel;

import org.apache.commons.configuration.XMLConfiguration;
import org.apache.commons.configuration.tree.ConfigurationNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import plugins.ICIIGraphicable;
import resources.CiiTreeManager;
import resources.DataGenerator;
import resources.DataRelays;
import resources.UltimateOPS;
import testy.MouseMotionEventDemo;
import testy.TestHardware;
import cii_functions.FCII_TRANSCEIVER;
import cii_functions.FCII_TRANSCEIVER.TEST_MODE;
import cii_functions.IDataCommuniactor;
import cii_lib.CCII_ACCESS_INTERF;
import cii_lib.CCII_COMPONENT;
import cii_lib.CIIdata;
import cii_lib_graph.elements.GUIUtils;

import componentEnhancement.ContextUtils;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class GCII_TRANSCEIVER extends javax.swing.JFrame implements ICIIGraphicable, IDataCommuniactor{
	
	private static final Logger log = LoggerFactory
			.getLogger(GCII_TRANSCEIVER.class);
	/**
	 * cii_lib_graph.GCII_TRANSCEIVER
	 */
	private static final long serialVersionUID = 8892971845121097783L;
	private JPanel defaultPanel;
	private JPanel jPanel1;
	private JScrollPane jScrollPane1;
	private JScrollPane jScrollPane2;
	private JButton jButton2;
	private JTextField readStaticRegField;
	private JButton jButton1;
	private JPanel jPanel6;
	private JPanel jPanel5;
	private JTabbedPane jTabbedPane1;
	private JPanel commonCfgPanel;
	private JButton loadCfgB;
	private JButton setupBut;
	private JLabel jLabel36;
	private JLabel jLabel35;
	private JLabel jLabel34;
	private JLabel jLabel33;
	private JLabel jLabel32;
	private JLabel jLabel31;
	private JLabel jLabel30;
	private JLabel jLabel29;
	private JLabel jLabel28;
	private JLabel jLabel27;
	private JLabel jLabel26;
	private JLabel jLabel25;
	private JLabel jLabel24;
	private JLabel jLabel23;
	private JLabel jLabel22;
	private JLabel jLabel21;
	private JLabel jLabel20;
	private JLabel jLabel19;
	private JLabel jLabel18;
	private JPanel jPanel12;
	private JPanel techSegPanel;
	private JButton jButton8;
	private JPanel jPanel11;
	private JScrollPane jScrollPane5;
	private JLabel jLabel17;
	private JLabel jLabel16;
	private JTextField logSpeedfield;
	private JLabel logIntervTxt;
	private JButton engageRndB;
	private JLabel randResTxt;
	private JButton jButtonSelect;
	private JTextPane logPane1;
	private JScrollPane jScrollPane4;
	private JButton jButton7;
	private JTextField delayField;
	private JLabel delayTxt;
	private JPanel jPanel9;
	private JButton autoButt;
	private JButton manualButton;
	private JLabel jLabel15;
	private JLabel jLabel14;
	private JLabel jico1;
	private JLabel jLabel13;
	private JTextField jTextField1;
	private JButton jButton6;
	private JLabel jLabel12;
	private JLabel jLabel11;
	private JCheckBox jCheckBox1;
	private JCheckBox jCheckBox2;
	private JButton jButton5;
	private JButton jButton4;
	private JCheckBox jCheckBox3;
	private JCheckBox xorCSCB;
	private JPanel jPanel10;
	private JCheckBox invClkBox;
	private JRadioButton notPhasedRB;
	private JRadioButton phasedRB;
	private ButtonGroup buttonGroup2;
	private JLabel jLabel10;
	private JRadioButton fallEdgeRB;
	private JRadioButton risinEdgeRB;
	private ButtonGroup buttonGroup1;
	private JLabel jLabel9;
	private JLabel jLabel8;
	private JLabel jLabel7;
	private JButton jButton3;
	private JPanel jPanel8;
	private JScrollPane jScrollPane3;
	private JPanel jPanel7;
	private JLabel jLabel6;
	private JLabel jLabel5;
	private JLabel jLabel4;
	private JLabel jLabel3;
	private JLabel jLabel2;
	private JLabel jLabel1;
	private JPanel jPanel4;
	private JTree jTree2;
	private JPanel jPanel3;
	private JTree jTree1;
	private JPanel jPanel2;
	private JButton staticWriteButton;
	private JTextField ww;
	
	private boolean canWork = false;
	private boolean autoCfg = true;
	private int verify = 0;
	private Icon gi = new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\Aqua-Ball-Green-16x16.png");
	private Icon ri = new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\Aqua-Ball-Red-16x16.png");

	private FCII_TRANSCEIVER funcions;
	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
		} catch(Exception e) {
			log.error("", e);
		}
	}
	
	private CCII_COMPONENT sender=null, receiver=null;
	private GInterfaceTerminal wordDataTestS;
	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				GCII_TRANSCEIVER inst = new GCII_TRANSCEIVER();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public GCII_TRANSCEIVER() {
		super();
		initGUI();
	}
	
	public GCII_TRANSCEIVER(CCII_COMPONENT send, CCII_COMPONENT rec) {
		sender = send;
		receiver = rec;
		//FIXME tu jest robione jeszcze na okolo
		ContextUtils cu = new ContextUtils(sender);
		CCII_COMPONENT tmp = cu.getChildByName("COMP_SEND");
		ContextUtils cSend = new ContextUtils(tmp);
		try {
			wordDataTestS = new GInterfaceTerminal(cSend.getInterfByName("WORD_TEST_DATA"));
			cu=null;cSend=null;
		} catch (Exception e) {
			cu=null;
			log.debug("eeee "+e);
		}
		try {
			initGUI();
		} catch (Exception e) {
			log.debug("my e: "+e.getStackTrace());
		}
		
	}
	
	public GCII_TRANSCEIVER(CCII_COMPONENT common) {
		sender = common;
		receiver = common;
		ContextUtils cu = new ContextUtils(sender.getInterfaces(),sender.getParams());
		try {
			this.wordDataTestS = new GInterfaceTerminal(cu.getInterfByName("WORD_TEST_DATA"));
			cu=null;
		} catch (Exception e) {
			cu=null;
			log.debug("eeee "+e);
		}
		initGUI();
		
	}
	
	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			{
				defaultPanel = new JPanel();
				getContentPane().add(defaultPanel, BorderLayout.CENTER);
				defaultPanel.setLayout(null);
				{
					jPanel1 = new JPanel();
					BorderLayout jPanel1Layout = new BorderLayout();
					defaultPanel.add(jPanel1);
					jPanel1.setLayout(jPanel1Layout);
					jPanel1.setBounds(0, 15, 306, 195);
					jPanel1.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)));
					{
						jPanel2 = new JPanel();
						jPanel1.add(jPanel2, BorderLayout.WEST);
						jPanel2.setPreferredSize(new java.awt.Dimension(28, 193));
						jPanel2.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0,0,0)));
						jPanel2.setLayout(null);
						{
							jLabel3 = new JLabel();
							jPanel2.add(jLabel3);
							jLabel3.setText("View");
							jLabel3.setBounds(1, 167, 24, 24);
							jLabel3.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\blinklist-24x24.png"));
							jLabel3.setToolTipText("Toggle view to show whole context or just transcievers");
							jLabel3.addMouseListener(new MouseAdapter() {
								public void mouseReleased(MouseEvent evt) {
									jLabel3.setBorder(null);
								}
								public void mousePressed(MouseEvent evt) {
									jLabel3.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
								}
								public void mouseClicked(MouseEvent evt) {
									if (jLabel3.getIcon().toString().equals("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\blinklist-24x24.png")) 
										jLabel3.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\blinklist-24x24b.png"));
									else jLabel3.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\blinklist-24x24.png"));
									log.info("Command: Sender {}", new Object[] { jLabel3.getText()});
								}
								});
						}
						{
							jLabel5 = new JLabel();
							jPanel2.add(jLabel5);
							jLabel5.setText("cmp");
							jLabel5.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\library-24x24.png"));
							jLabel5.setToolTipText("Open component ...");
							jLabel5.setBounds(1, 1, 24, 24);
							jLabel5.addMouseListener(new MouseAdapter() {
								public void mouseReleased(MouseEvent evt) {
									jLabel5.setBorder(null);
								}
								public void mousePressed(MouseEvent evt) {
									jLabel5.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
								}
								public void mouseClicked(MouseEvent evt) {
									log.info("Command: Sender {}", new Object[] { jLabel5.getText() });
								}
							});
						}
						{
							jLabel7 = new JLabel();
							jPanel2.add(jLabel7);
							jLabel7.setText("snd");
							jLabel7.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\recycle-24x24S.png"));
							jLabel7.setToolTipText("Mark sender ...");
							jLabel7.setBounds(1, 28, 24, 24);
							jLabel7.addMouseListener(new MouseAdapter() {
								public void mouseReleased(MouseEvent evt) {
									jLabel7.setBorder(null);
								}
								public void mousePressed(MouseEvent evt) {
									if (jLabel7.isEnabled()) jLabel7.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
								}
								public void mouseClicked(MouseEvent evt) {
									if (!jLabel7.isEnabled()) return; 
									selectSender();
									DefaultMutableTreeNode send = (DefaultMutableTreeNode)jTree1.getLastSelectedPathComponent();
									log.info("Command: Sender {} {}", new Object[] { jLabel7.getText(), send.getUserObject() });
								}
							});
						}
					}
					{
						jScrollPane1 = new JScrollPane();
						jPanel1.add(jScrollPane1, BorderLayout.CENTER);
						{
							jTree1 = getSenderTree();
							jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
							jTree1.setCellRenderer(UltimateOPS.treeRenderer());
							jScrollPane1.setViewportView(jTree1);
							defaultPanel.addMouseMotionListener(new MouseMotionEventDemo(defaultPanel));
						}
					}
				}
				{
					jPanel3 = new JPanel();
					defaultPanel.add(jPanel3);
					BorderLayout jPanel3Layout = new BorderLayout();
					jPanel3.setBorder(BorderFactory.createMatteBorder(1,1,1,1,new java.awt.Color(0,0,0)));
					jPanel3.setLayout(jPanel3Layout);
					jPanel3.setBounds(316, 15, 300, 196);
					{
						jPanel4 = new JPanel();
						jPanel3.add(jPanel4, BorderLayout.EAST);
						jPanel4.setPreferredSize(new java.awt.Dimension(28, 194));
						jPanel4.setBorder(BorderFactory.createMatteBorder(1,1,1,1,new java.awt.Color(0,0,0)));
						jPanel4.setLayout(null);
						{
							jLabel4 = new JLabel();
							jPanel4.add(jLabel4);
							jLabel4.setText("View");
							jLabel4.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\blinklist-24x24.png"));
							jLabel4.setToolTipText("Toggle view to show whole context or just transcievers");
							jLabel4.setBounds(1, 169, 24, 24);
							jLabel4.addMouseListener(new MouseAdapter() {
								public void mouseReleased(MouseEvent evt) {
									jLabel4.setBorder(null);
								}
								public void mousePressed(MouseEvent evt) {
									jLabel4.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
								}
								public void mouseClicked(MouseEvent evt) {
									if (jLabel4.getIcon().toString().equals("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\blinklist-24x24.png")) 
										jLabel4.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\blinklist-24x24b.png"));
									else jLabel4.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\blinklist-24x24.png"));
									log.info("Command: Receiver {}", new Object[] { jLabel4.getText()});
								}
							});
						}
						{
							jLabel6 = new JLabel();
							jPanel4.add(jLabel6);
							jPanel4.add(getJLabel8());
							jLabel6.setText("cmp");
							jLabel6.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\library-24x24.png"));
							jLabel6.setToolTipText("Open component ...");
							jLabel6.setBounds(1, 1, 24, 24);
							jLabel6.addMouseListener(new MouseAdapter() {
								public void mouseReleased(MouseEvent evt) {
									jLabel6.setBorder(null);
								}
								public void mousePressed(MouseEvent evt) {
									jLabel6.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
								}
								public void mouseClicked(MouseEvent evt) {
									log.info("Command: Receiver {}", new Object[] { jLabel5.getText() });
								}
							});
						}
					}
					{
						jScrollPane2 = new JScrollPane();
						jPanel3.add(jScrollPane2, BorderLayout.CENTER);
						{
							jTree2 = getReceiverTree();
							jTree2.setLayout(null);
							jTree2.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
							jTree2.setCellRenderer(UltimateOPS.treeRenderer());
							jScrollPane2.setViewportView(jTree2);
						}
					}
				}
				{
					jLabel1 = new JLabel();
					defaultPanel.add(jLabel1);
					jLabel1.setText("Sender");
					jLabel1.setBounds(41, -1, 257, 16);
					jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel1.setBackground(new java.awt.Color(221,221,221));
					jLabel1.setForeground(new java.awt.Color(0,128,128));
					jLabel1.setFont(new java.awt.Font("Tahoma",1,11));
				}
				{
					jLabel2 = new JLabel();
					defaultPanel.add(jLabel2);
					jLabel2.setText("Receiver");
					jLabel2.setHorizontalAlignment(SwingConstants.CENTER);
					jLabel2.setBackground(new java.awt.Color(221,221,221));
					jLabel2.setBounds(326, 0, 256, 13);
					jLabel2.setForeground(new java.awt.Color(84,0,168));
					jLabel2.setFont(new java.awt.Font("Tahoma",1,11));
				}
				{
					commonCfgPanel = new JPanel();
					defaultPanel.add(commonCfgPanel);
					commonCfgPanel.setLayout(null);
					commonCfgPanel.setBounds(23, 216, 565, 152);
					commonCfgPanel.setBorder(BorderFactory.createTitledBorder(new LineBorder(new java.awt.Color(128,0,64), 1, true), "Common action:", TitledBorder.LEADING, TitledBorder.DEFAULT_POSITION));
					{
						jTabbedPane1 = new JTabbedPane();
//						jTabbedPane1.setEnabled(false);
						commonCfgPanel.add(jTabbedPane1);
						jTabbedPane1.setBounds(10, 14, 545, 128);
						{
							jPanel7 = new JPanel();
							jTabbedPane1.addTab("Properties", null, jPanel7, null);
							BorderLayout jPanel7Layout = new BorderLayout();
							jPanel7.setLayout(jPanel7Layout);
							jPanel7.setBounds(17, 44, 360, 48);
							jPanel7.add(getJScrollPane5(), BorderLayout.CENTER);
						}
						{
						jPanel5 = new JPanel();
							jTabbedPane1.addTab("Static test", null, jPanel5, null);
							jPanel5.setLayout(null);
							{
								jButton1 = new JButton();
								jPanel5.add(jButton1);
								jButton1.setText("Engage");
								jButton1.setBounds(447, 73, 82, 19);
								jButton1.setToolTipText("Apply static test mode");
								jButton1.setBackground(new java.awt.Color(128,0,255));
								jButton1.setForeground(new java.awt.Color(0,0,160));
								jButton1.setFont(new java.awt.Font("Tahoma",1,11));
								jButton1.addActionListener(new ActionListener() {
									public void actionPerformed(ActionEvent evt) { 
										log.info("Command: Static {} delay {}", new Object[] {jButton1.getToolTipText(), delayField.getText()});
										engageStatic();
									}
								});
							}
							{
								readStaticRegField = getStaticText();
								readStaticRegField.setEditable(false);
								jPanel5.add(readStaticRegField);
								readStaticRegField.setText("0");
								readStaticRegField.setFont(new java.awt.Font("Tahoma",1,11));
								readStaticRegField.setForeground(new java.awt.Color(0,128,128));
								readStaticRegField.setBounds(197, 11, 180, 21);
							}
							{
								jButton2 = getStaticButton();
								jPanel5.add(jButton2);
								jPanel5.add(getJLabel11());
								jPanel5.add(getJLabel12());
								jPanel5.add(getJButton6());
//								jPanel5.add(getJTextField1(null));
								jPanel5.add(getJLabel13());
								jPanel5.add(getJico1());
								jPanel5.add(getJLabel14());
								jPanel5.add(getJLabel15());
								jPanel5.add(getManualButton());
								jPanel5.add(getJPanel9());
								jButton2.setText("Read");
								jButton2.setToolTipText("Read current value");
								jButton2.setBounds(130, 11, 57, 21);
							}
						}
						{
							jPanel6 = new JPanel();
							jTabbedPane1.addTab("Random test", null, jPanel6, null);
							jPanel6.setLayout(null);
							jPanel6.add(getJScrollPane4());
							jPanel6.add(getJButtonSelect());
							jPanel6.add(getRandResTxt());
							jPanel6.add(getEngageRndB());
							jPanel6.add(getLogIntervTxt());
							jPanel6.add(getLogSpeedfield());
							jPanel6.add(getJLabel16());
							jPanel6.add(getJLabel17());
							jPanel6.add(getJButton8());
							jPanel6.add(getJButton7x());
						}
						{
							jScrollPane3 = new JScrollPane();
							jScrollPane3.getHorizontalScrollBar().setEnabled(true);
							jScrollPane3.getHorizontalScrollBar().setVisible(true);
							jScrollPane3.getVerticalScrollBar().setUnitIncrement(5);
							jScrollPane3.getVerticalScrollBar().setValue(1);
							jTabbedPane1.addTab("Primary configuration", null, jScrollPane3, null);
							{
								jPanel8 = new JPanel();
								jScrollPane3.setViewportView(jPanel8);
								jPanel8.setPreferredSize(new java.awt.Dimension(521, 160));
								jPanel8.setLayout(null);
								{
									jButton3 = new JButton();
									jPanel8.add(jButton3);
									jPanel8.add(getJLabel9());
									jPanel8.add(getRisinEdgeRB());
									jPanel8.add(getFallEdgeRB());
									jPanel8.add(getJLabel10());
									jPanel8.add(getPhasedRB());
									jPanel8.add(getNotPhasedRB());
									jPanel8.add(getInvClkBox());
									jPanel8.add(getJCheckBox1());
									jPanel8.add(getJCheckBox2());
									jPanel8.add(getJPanel10());
									jPanel8.add(getJButton4());
									jPanel8.add(getJLabel36());
									jPanel8.add(getJButton5());
									jPanel8.add(getSetupBut());
									jPanel8.add(getLoadCfgB());
									getButtonGroup1();
									getButtonGroup2();
									jButton3.setText("Defaults");
									jButton3.setBounds(423, 25, 86, 20);
									jButton3.addActionListener(new ActionListener() {
										public void actionPerformed(ActionEvent evt) { 
											log.info("Command: {}", evt.getActionCommand());
											if (!xorCSCB.isSelected()) xorCSCB.doClick();
											if (!jCheckBox3.isSelected()) jCheckBox3.doClick();
											if (!risinEdgeRB.isSelected()) risinEdgeRB.doClick();
											if (!phasedRB.isSelected()) phasedRB.doClick();
										}
									});
								}
							}
						}
					}
				}
			}
			GUIUtils.enableContainer(commonCfgPanel, false);
			pack();
			defaultPanel.setSize(632, 423);
			defaultPanel.setPreferredSize(new java.awt.Dimension(624, 379));
			this.setSize(632, 405);
		} catch (Exception e) {
			log.error("", e);
		}
	}
	
	
	public JTree getSenderTree() {
		if (sender==null) return new JTree();
		JTree stree = new JTree();
		DefaultMutableTreeNode tn = new DefaultMutableTreeNode("empty");
		//TODO dla testow P.Romanowski
		//tn = UltimateOPS.buildTreeModel(sender);
		tn = CiiTreeManager.buildTreeModel(sender);
		DefaultTreeModel dtm = new DefaultTreeModel(tn);
		stree.setModel(dtm);
		return stree;
	}
	public JTree getReceiverTree() {
		if (receiver==null) return new JTree();
		JTree rtree = new JTree();
		DefaultMutableTreeNode tn = new DefaultMutableTreeNode("empty");
		//TODO dla testow P.Romanowski
//		tn = UltimateOPS.buildTreeModel(receiver);
		tn = CiiTreeManager.buildTreeModel(receiver);
		DefaultTreeModel dtm = new DefaultTreeModel(tn);
		rtree.setModel(dtm);
		return rtree;
	}

	public JTextField getStaticText() {
		if (sender==null || receiver==null) return new JTextField();
			JTextField jt = wordDataTestS.getReadWriteTextField();
			return jt;
	}
	
	public JButton getStaticButton() {
		if (sender==null) return new JButton();
			JButton jb = wordDataTestS.getReadButton();
			return jb;
	}
	
	public JPanel getDefaultPanel() {
		return defaultPanel;
	}

	public CCII_COMPONENT getSender() {
		return sender;
	}

	public void setSender(CCII_COMPONENT sender) {
		this.sender = sender;
	}

	public CCII_COMPONENT getReceiver() {
		return receiver;
	}

	public void setReceiver(CCII_COMPONENT receiver) {
		this.receiver = receiver;
	}
	
	private void selectSender() {
//		jLabel7.setEnabled(false);
		DefaultMutableTreeNode send = (DefaultMutableTreeNode)jTree1.getLastSelectedPathComponent();
		CCII_COMPONENT cm = (CCII_COMPONENT)send.getUserObject();
		sender = cm;
//		log.debug("sel: "+cm.getChildren().size());
		String tmp = new String("<html><body bgcolor=#00FF99>"+ cm.GetCompID()+" "+cm.Name()+"</body></html>");
		send.setUserObject(tmp);
		jLabel7.setEnabled(false);
		verify=verify|1;
		verifyCmpSet();
		//Dialog dl = new Dialog(this,"Unable to comply: selected item is not transciever object",1);
	}

	private void selectReceiver() {
//		jLabel7.setEnabled(false);
		DefaultMutableTreeNode rcv = (DefaultMutableTreeNode)jTree2.getLastSelectedPathComponent();
		CCII_COMPONENT cm = (CCII_COMPONENT)rcv.getUserObject();
		receiver=cm;
		String tmp = new String("<html><body bgcolor=#55BBEA>"+ cm.GetCompID()+" "+cm.Name()+"</body></html>");
		rcv.setUserObject(tmp);
		jTree2.repaint();
		jLabel8.setEnabled(false);
		verify=verify|2;
		verifyCmpSet();
	}
	
	private void verifyCmpSet() {
		int repL = Integer.toBinaryString(verify).length();
		if (repL<2) return;
		int ones = (int)Math.pow(2, repL)-1;
		if ((verify^ones)==0) {
			log.debug("GCII_TRANSCIVER: receiver and sender are set properly");
			canWork=true;
			funcions = new FCII_TRANSCEIVER(sender,receiver);
			GUIUtils.enableContainer(commonCfgPanel, true);
			printDescriptions();
		}
	}
	
	private void printDescriptions() {
		ContextUtils cS = new ContextUtils(sender);
		ContextUtils cR = new ContextUtils(receiver);
		ContextUtils cSen = new ContextUtils(cS.getChildByName("COMP_SEND"));
//		ContextUtils cRcv = new ContextUtils(cR.getChildByName("COMP_REC"));
		ContextUtils cMux = new ContextUtils(cS.getChildByName("COMP_MUX"));
		ContextUtils cDmx = new ContextUtils(cR.getChildByName("COMP_DEMUX"));
		jLabel20.setText(""+cMux.getParamByName("IPAR_MUX_WIDTH").getValue());
		jLabel20.setToolTipText("IPAR_MUX_WIDTH");
		jLabel21.setText(""+cMux.getParamByName("IPAR_MUX_MULTIPL").getValue());
		jLabel21.setToolTipText("IPAR_MUX_MULTIPL");
		jLabel24.setText(""+cSen.getParamByName("IPAR_PART_WIDTH").getValue());
		jLabel24.setToolTipText("IPAR_PART_WIDTH");
		jLabel25.setText(""+cSen.getParamByName("IPAR_PART_NUM").getValue());
		jLabel25.setToolTipText("IPAR_PART_NUM");
		jLabel27.setText(""+cSen.getParamByName("IPAR_TRANSM_DATA_WIDTH").getValue());
		jLabel27.setToolTipText("IPAR_TRANSM_DATA_WIDTH");
		jLabel31.setText(""+cSen.getParamByName("IPAR_DATA_WIDTH").getValue());
		jLabel31.setToolTipText("IPAR_DATA_WIDTH");
		jLabel33.setText(""+cSen.getParamByName("IPAR_CHECK_WIDTH").getValue());
		jLabel33.setToolTipText("IPAR_CHECK_WIDTH");
		jLabel35.setText(""+cMux.getParamByName("IPAR_CLOCK_MULTIPL").getValue());
		jLabel35.setToolTipText("IPAR_CLOCK_MULTIPL");
		try {
			GInterfaceTerminal gitmp = new GInterfaceTerminal(cDmx.getInterfByName("BITS_DATA_DELAY"));
			ww = gitmp.getReadWriteTextField();
			jPanel8.add(ww);
			ww.setBounds(303, 41, 96, 18);
			log.debug("delayBitsField overide");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			log.error("", e);
		}
	}
	
	private JLabel getJLabel8() {
		if (jLabel8 == null) {
			jLabel8 = new JLabel();
			jLabel8.setText("rcv");
			jLabel8.setIcon(new ImageIcon("D:\\_przegrywane_dyskD\\multimedia\\obrazy\\recycle-24x24R.png"));
			jLabel8.setToolTipText("Mark receiver ...");
			jLabel8.setBounds(1, 28, 24, 24);
			jLabel8.addMouseListener(new MouseAdapter() {
				public void mouseReleased(MouseEvent evt) {
					jLabel8.setBorder(null);
				}
				public void mousePressed(MouseEvent evt) {
					if (jLabel8.isEnabled()) jLabel8.setBorder(new SoftBevelBorder(BevelBorder.LOWERED, null, null, null, null));
				}
				public void mouseClicked(MouseEvent evt) {
					if (jLabel8.isEnabled()) {
						selectReceiver();
						DefaultMutableTreeNode send = (DefaultMutableTreeNode)jTree2.getLastSelectedPathComponent();
						log.info("Command: Receiver {} {}", new Object[] { jLabel8.getText(), send.getUserObject() });
					}
				}
			});
		}
		return jLabel8;
	}
	
	private JLabel getJLabel9() {
		if(jLabel9 == null) {
			jLabel9 = new JLabel();
			jLabel9.setText("Chose trigger edge: ");
			jLabel9.setBounds(10, 5, 99, 14);
		}
		return jLabel9;
	}
	
	private ButtonGroup getButtonGroup1() {
		if(buttonGroup1 == null) {
			buttonGroup1 = new ButtonGroup();
			buttonGroup1.add(getRisinEdgeRB());
			buttonGroup1.add(getFallEdgeRB());
		}
		return buttonGroup1;
	}
	
	private JRadioButton getRisinEdgeRB() {
		if(risinEdgeRB == null) {
			risinEdgeRB = new JRadioButton();
			risinEdgeRB.setText("Rising edge");
			risinEdgeRB.setBounds(134, 1, 81, 23);
			risinEdgeRB.setEnabled(canWork);
			risinEdgeRB.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					try {
						//TODO moze jakis ConfigurationManager 
//						final ContextUtils cSen = new ContextUtils(sender);
						ContextUtils cRcv = new ContextUtils(receiver);
//						cMux = new ContextUtils(cSen.getChildByName("COMP_MUX"));
						ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_DEMUX"));
						XMLConfiguration xDmx = ContextUtils.getConfigFromCU(cDmx);
						
//						XMLConfiguration xMux = ContextUtils.getConfigFromCU(cMux);
						XMLConfiguration xV = (XMLConfiguration)xDmx.clone();
//						XMLConfiguration xM = (XMLConfiguration)xMux.clone();
//						xV.setProperty("BITS_CLK_INV", 1);
						xV.setProperty("BITS_MUX_CLK_INV",1);
//						xM.setProperty("BITS_CLK_INV", 1);
//						cMux.getInterfByName("BITS_CLK_INV").Write(0, 0, new CIIdata(1,1));
						cDmx.getInterfByName("BITS_MUX_CLK_INV").Write(0, 0, new CIIdata(1,1));
//						cDmx.getInterfByName("BITS_CLK_INV").Write(0, 0, new CIIdata(1,1));
						xV.save(xDmx.getFile().getAbsolutePath().replace("component", "version1.0"));
//						xM.save(xMux.getFile().getAbsolutePath().replace("component", "version1.0"));
//						xDmx.setProperty("BITS_CLK_INV", xDmx.getFile().getAbsolutePath().replace("component", "version1.0"));
						xDmx.setProperty("BITS_MUX_CLK_INV", xDmx.getFile().getAbsolutePath().replace("component", "version1.0"));
//						xMux.setProperty("BITS_CLK_INV", xMux.getFile().getAbsolutePath().replace("component", "version1.0"));
						xDmx.save();
//						xMux.save();
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return risinEdgeRB;
	}
	
	private JRadioButton getFallEdgeRB() {
		if(fallEdgeRB == null) {
			fallEdgeRB = new JRadioButton();
			fallEdgeRB.setText("Falling edge");
			fallEdgeRB.setBounds(237, 1, 83, 23);
			fallEdgeRB.setEnabled(canWork);
			fallEdgeRB.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					ContextUtils cRcv = new ContextUtils(receiver);
					ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_DEMUX"));
					try {
						//TODO moze jakis ConfigurationManager 
						XMLConfiguration xDmx = ContextUtils.getConfigFromCU(cDmx);
						XMLConfiguration xV = (XMLConfiguration)xDmx.clone();
						xV.setProperty("BITS_MUX_CLK_INV",0);
						
						cDmx.getInterfByName("BITS_MUX_CLK_INV").Write(0, 0, new CIIdata(1,0));
						
						xV.save(xDmx.getFile().getAbsolutePath().replace("component", "version1.0"));
						xDmx.setProperty("BITS_MUX_CLK_INV", xDmx.getFile().getAbsolutePath().replace("component", "version1.0"));
						xDmx.save();
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return fallEdgeRB;
	}
	
	private JLabel getJLabel10() {
		if(jLabel10 == null) {
			jLabel10 = new JLabel();
			jLabel10.setText("Phase shifted edge:");
			jLabel10.setBounds(10, 25, 101, 12);
		}
		return jLabel10;
	}
	
	private ButtonGroup getButtonGroup2() {
		if(buttonGroup2 == null) {
			buttonGroup2 = new ButtonGroup();
			buttonGroup2.add(getPhasedRB());
			buttonGroup2.add(getNotPhasedRB());
		}
		return buttonGroup2;
	}
	
	private JRadioButton getPhasedRB() {
		if(phasedRB == null) {
			phasedRB = new JRadioButton();
			phasedRB.setText("Yes");
			phasedRB.setBounds(134, 20, 43, 20);
			phasedRB.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					ContextUtils cRcv = new ContextUtils(receiver);
					ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_DEMUX"));
					try {

						XMLConfiguration xDmx = ContextUtils.getConfigFromCU(cDmx);
						//TODO find versions
						String verPath=null;
						for (Object node : xDmx.getRoot().getChildren().toArray()) {
							verPath = ((ConfigurationNode)node).getValue().toString();
							log.debug("node: " + node.toString());
							if (verPath.equals("COMP_DEMUX")) { verPath=null; continue; }
							log.debug("klucz "+ ((ConfigurationNode)node).getValue());
							if (verPath!=null) break;
						}
						XMLConfiguration xV ;
						if (verPath==null) xV =(XMLConfiguration)xDmx.clone();
						else xV = new XMLConfiguration(verPath);
						cDmx.getInterfByName("BITS_MUX_CLK90").Write(0, 0, new CIIdata(1,1));
						phasedRB.setToolTipText(UltimateOPS.getCIIHTMLTooltip(cDmx.getInterfByName("BITS_MUX_CLK90").GetItem(), ""));
						xV.setProperty("BITS_MUX_CLK90",1);
						xV.save(xDmx.getFile().getAbsolutePath().replace("component", "version1.0"));
						xDmx.setProperty("BITS_MUX_CLK90", xDmx.getFile().getAbsolutePath().replace("component", "version1.0"));
						xDmx.save();
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return phasedRB;
	}
	
	private JRadioButton getNotPhasedRB() {
		if(notPhasedRB == null) {
			notPhasedRB = new JRadioButton();
			notPhasedRB.setText("No");
			notPhasedRB.setBounds(237, 20, 39, 20);
			notPhasedRB.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					ContextUtils cRcv = new ContextUtils(receiver);
					ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_DEMUX"));
					try {
						cDmx.getInterfByName("BITS_MUX_CLK90").Write(0, 0, new CIIdata(1,0));
						phasedRB.setToolTipText(UltimateOPS.getCIIHTMLTooltip(cDmx.getInterfByName("BITS_MUX_CLK90").GetItem(), ""));
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return notPhasedRB;
	}
	
	private JCheckBox getInvClkBox() {
		if(invClkBox == null) {
			invClkBox = new JCheckBox();
			invClkBox.setText("Invert clock: ");
			invClkBox.setBounds(67, 99, 94, 15);
			invClkBox.setHorizontalTextPosition(SwingConstants.LEADING);
			invClkBox.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					ContextUtils cSen = new ContextUtils(sender);
					ContextUtils cRcv = new ContextUtils(receiver);
					ContextUtils cMux = new ContextUtils(cSen.getChildByName("COMP_MUX"));
					ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_DEMUX"));
					try {
						cMux.getInterfByName("BITS_CLK_INV").Write(0, 0, new CIIdata(1,invClkBox.isSelected()?1:0));
						cDmx.getInterfByName("BITS_CLK_INV").Write(0, 0, new CIIdata(1,invClkBox.isSelected()?1:0));
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return invClkBox;
	}
	
	private JCheckBox getJCheckBox1() {
		if(jCheckBox1 == null) {
			jCheckBox1 = new JCheckBox();
			jCheckBox1.setText("Delay by one clock state: ");
			jCheckBox1.setHorizontalTextPosition(SwingConstants.LEADING);
			jCheckBox1.setBounds(6, 41, 152, 18);
			jCheckBox1.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					ContextUtils cRcv = new ContextUtils(receiver);
					ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_DEMUX"));
					try {
						cDmx.getInterfByName("BITS_MUX_REG_ADD").Write(0, 0, new CIIdata(1,jCheckBox1.isSelected()?1:0));
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return jCheckBox1;
	}
	
	private JCheckBox getJCheckBox2() {
		if(jCheckBox2 == null) {
			jCheckBox2 = new JCheckBox();
			jCheckBox2.setText("Multiplex swap: ");
			jCheckBox2.setHorizontalTextPosition(SwingConstants.LEADING);
			jCheckBox2.setBounds(225, 99, 111, 15);
			jCheckBox2.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					ContextUtils cSen = new ContextUtils(sender);
					ContextUtils cRcv = new ContextUtils(receiver);
					ContextUtils cMux = new ContextUtils(cSen.getChildByName("COMP_SEND"));
					ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_REC"));
					try {
						cMux.getInterfByName("BITS_SWAP_ENA").Write(0, 0, new CIIdata(1,jCheckBox2.isSelected()?1:0));
						cDmx.getInterfByName("BITS_SWAP_ENA").Write(0, 0, new CIIdata(1,jCheckBox2.isSelected()?1:0));
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return jCheckBox2;
	}
	
	private JPanel getJPanel10() {
		if(jPanel10 == null) {
			jPanel10 = new JPanel();
			jPanel10.setLayout(null);
			jPanel10.setBounds(10, 61, 390, 31);
			jPanel10.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
			jPanel10.add(getXorCSCB());
			jPanel10.add(getJCheckBox3());
		}
		return jPanel10;
	}
	
	private JCheckBox getXorCSCB() {
		if(xorCSCB == null) {
			xorCSCB = new JCheckBox();
			xorCSCB.setText("XOR control sum: ");
			xorCSCB.setBounds(21, 6, 128, 18);
			xorCSCB.setFont(new java.awt.Font("Tahoma",1,11));
			xorCSCB.setHorizontalTextPosition(SwingConstants.LEADING);
			xorCSCB.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					ContextUtils cSen = new ContextUtils(sender);
					ContextUtils cRcv = new ContextUtils(receiver);
					ContextUtils cMux = new ContextUtils(cSen.getChildByName("COMP_SEND"));
					ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_REC"));
					try {
						cMux.getInterfByName("BITS_CHECK_ENA").Write(0, 0, new CIIdata(1,xorCSCB.isSelected()?1:0));
						cDmx.getInterfByName("BITS_CHECK_ENA").Write(0, 0, new CIIdata(1,xorCSCB.isSelected()?1:0));
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return xorCSCB;
	}
	
	private JCheckBox getJCheckBox3() {
		if(jCheckBox3 == null) {
			jCheckBox3 = new JCheckBox();
			jCheckBox3.setText("XOR time marker: ");
			jCheckBox3.setHorizontalTextPosition(SwingConstants.LEADING);
			jCheckBox3.setFont(new java.awt.Font("Tahoma",1,11));
			jCheckBox3.setBounds(189, 6, 128, 18);
			jCheckBox3.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					ContextUtils cSen = new ContextUtils(sender);
					ContextUtils cRcv = new ContextUtils(receiver);
					ContextUtils cMux = new ContextUtils(cSen.getChildByName("COMP_SEND"));
					ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_REC"));
					try {
						cMux.getInterfByName("BITS_CHECK_DATA_ENA").Write(0, 0, new CIIdata(1,jCheckBox3.isSelected()?1:0));
						cDmx.getInterfByName("BITS_CHECK_DATA_ENA").Write(0, 0, new CIIdata(1,jCheckBox3.isSelected()?1:0));
					} catch (Exception e) {
						log.error("", e);
					}
				}
			});
		}
		return jCheckBox3;
	}
	
	private JButton getJButton4() {
		if(jButton4 == null) {
			jButton4 = new JButton();
			jButton4.setText("Clear");
			jButton4.setBounds(423, 47, 86, 20);
			jButton4.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					if (xorCSCB.isSelected()) xorCSCB.doClick();
					if (jCheckBox3.isSelected()) jCheckBox3.doClick();
					if (risinEdgeRB.isSelected()) risinEdgeRB.doClick();
					if (phasedRB.isSelected()) phasedRB.doClick();
				
				}
			});
		}
		return jButton4;
	}
	
	private JButton getJButton5() {
		if(jButton5 == null) {
			jButton5 = new JButton();
			jButton5.setText("Calibrate");
			jButton5.setBounds(423, 69, 86, 20);
			jButton5.setFont(new java.awt.Font("Tahoma",1,11));
			jButton5.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					TEST_MODE tmp=TEST_MODE.STATIC;
					ContextUtils cR = new ContextUtils(receiver);
					ContextUtils cRcv = new ContextUtils(cR.getChildByName("COMP_REC"));
					try {
						if (cRcv.getInterfByName("BITS_TEST_RAND_ENA").readSimple()==0) tmp = TEST_MODE.STATIC; 
						else tmp = TEST_MODE.RANDOM;
					} catch (Exception e) {
						// TODO Auto-generated catch block
						log.error("", e);
					}
					new resources.Dialog(null,"Calibration mode: "+tmp, 2).setVisible(true);
					funcions.calibrate(tmp);
				}
			});
		}
		return jButton5;
	}

	/* (non-Javadoc)
	 * @see plugins.ICIIGraphicable#getCustomPane(java.lang.String)
	 */
	@Override
	public JPanel getCustomPane(String xmlconfig) {
		// TODO Auto-generated method stub
		return null;
	}

	/* (non-Javadoc)
	 * @see plugins.ICIIGraphicable#getDefaultPane()
	 */
	@Override
	public JPanel getDefaultPane() {
		// TODO Auto-generated method stub
		return defaultPanel;
	}

	/* (non-Javadoc)
	 * @see plugins.ICIIGraphicable#getGCIIName()
	 */
	@Override
	public String getGCIIName() {
		// TODO Auto-generated method stub
		return null;
	}
	
	private JLabel getJLabel11() {
		if(jLabel11 == null) {
			jLabel11 = new JLabel();
			jLabel11.setText("Sender current value: ");
			jLabel11.setBounds(17, 14, 109, 14);
		}
		return jLabel11;
	}
	
	private JLabel getJLabel12() {
		if(jLabel12 == null) {
			jLabel12 = new JLabel();
			jLabel12.setText("Receiver current value: ");
			jLabel12.setBounds(10, 34, 120, 14);
		}
		return jLabel12;
	}
	
	private JButton getJButton6() {
		if(jButton6 == null) {
			jButton6 = new JButton();
			jButton6.setText("Read");
			jButton6.setToolTipText("Read current value");
			jButton6.setBounds(130, 31, 57, 21);
		}
		return jButton6;
	}
	
	private JTextField getJTextField1(JTextField st) {
		if(st == null) {
			st = new JTextField();
		}
			st.setText("0");
			st.setForeground(new java.awt.Color(84,0,168));
			st.setBounds(197, 31, 180, 21);
			st.setFont(new java.awt.Font("Tahoma",1,11));
		return st;
	}
	
	private JLabel getJLabel13() {
		if(jLabel13 == null) {
			jLabel13 = new JLabel();
			jLabel13.setText("Comparation status: ");
			jLabel13.setBounds(25, 55, 104, 14);
		}
		return jLabel13;
	}
	
	private JLabel getJico1() {
		if(jico1 == null) {
			jico1 = new JLabel();
			jico1.setIcon(gi);
			jico1.setEnabled(true);
			jico1.setBounds(147, 52, 21, 21);
			jico1.addVetoableChangeListener(new VetoableChangeListener() {
				public void vetoableChange(PropertyChangeEvent evt) {
					log.debug("jico1.vetoableChange, event="+evt);
					//TODO add your code for jico1.vetoableChange
				}
			});
		}
		return jico1;
	}

	protected void engageStatic() {
		TestHardware.incrementType =-1;
		Object[] options = { "Proceed", "Cancel" };
		JOptionPane jop = new JOptionPane(
				"<html>Detected Random test mode<br>" +
				"Please, confirm Static test mode.</html>",
				JOptionPane.WARNING_MESSAGE,
				JOptionPane.DEFAULT_OPTION,
				null,
				options);
		JDialog ds = jop.createDialog("Warning");
		ds.setVisible(true);
//		JOptionPane.showOptionDialog(null, 
//				"<html>Detected random test mode<br>Click</html>", 
//				"Warning", 
//				JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
//		null, options, options[0]);
		String selectedValue = new String(""+jop.getValue());
		if (selectedValue.equals("Proceed")) {
			log.info("Command : Proceed");
			ContextUtils cR = new ContextUtils(receiver);
			ContextUtils cRcv = new ContextUtils(cR.getChildByName("COMP_REC"));
			ContextUtils cS = new ContextUtils(sender);
			ContextUtils cSen = new ContextUtils(cS.getChildByName("COMP_SEND"));
			try {
				CCII_ACCESS_INTERF tst = cRcv.getInterfByName("WORD_TEST_OR_DATA");
				GInterfaceTerminal recT = new GInterfaceTerminal(cRcv.getInterfByName("WORD_TEST_DATA"));
//				jPanel5.getComponent(n)
				jTextField1 = new JTextField();
				readStaticRegField.setEditable(true);
				jTextField1.setVisible(false);
				JTextField jt =getJTextField1(recT.getReadWriteTextField());
				jt.setVisible(true);
				jTextField1 = jt;
				jPanel5.add(jTextField1);
				jPanel5.add(getstaticWriteButton());
				jButton6.setVisible(false);
				JButton jb = recT.getReadButton();
				jb.setBounds(130, 31, 57, 21);
				jb.setVisible(true);
				jPanel5.add(jb);
				jPanel5.revalidate();
					cRcv.getInterfByName("BITS_TEST_ENA").Write(0, 0, new CIIdata(1,1));
					cSen.getInterfByName("BITS_TEST_ENA").Write(0, 0, new CIIdata(1,1));
					cRcv.getInterfByName("BITS_TEST_RAND_ENA").writeSimple(0);
					cSen.getInterfByName("BITS_TEST_RAND_ENA").writeSimple(0);
				if (tst.readSimple()==0) {
					jLabel14.setEnabled(true);
					jLabel14.setIcon(gi);
//					jico1.firePropertyChange("lab", oldValue, newValue)
				} else {
					jLabel14.setEnabled(true);
					jLabel14.setIcon(ri);
				}
			} catch (Exception e) {
				log.error("", e);
			}
		} else {
			log.info("Command: Cancel");
			return;
		}
	    log.debug("Start reading Receiver");
	    
	}
	
	protected void engageRand() {
		TestHardware.incrementType=1;
		CCII_ACCESS_INTERF intr;
		if (engageRndB.getText().equals("Engage")) {
			engageRndB.setText("Stop");
			ContextUtils cR = new ContextUtils(receiver);
			ContextUtils cRcv = new ContextUtils(cR.getChildByName("COMP_REC"));
			ContextUtils cS = new ContextUtils(sender);
			ContextUtils cSen = new ContextUtils(cS.getChildByName("COMP_SEND"));
			try {
				cRcv.getInterfByName("BITS_TEST_ENA").Write(0, 0,
						new CIIdata(1, 1));
				cSen.getInterfByName("BITS_TEST_ENA").Write(0, 0,
						new CIIdata(1, 1));
				cRcv.getInterfByName("BITS_TEST_RAND_ENA").Write(0, 0,
						new CIIdata(1, 1));
				cSen.getInterfByName("BITS_TEST_RAND_ENA").Write(0, 0,
						new CIIdata(1, 1));
				intr = cSen.getInterfByName("WORD_TEST_DATA");
				new DataGenerator(new Integer(logSpeedfield.getText()),
						this, intr,"RAND_SND");
				intr = cRcv.getInterfByName("WORD_TEST_DATA");
				new DataGenerator(new Integer(logSpeedfield.getText()),
						this, intr,"RAND_REC");
				new DataGenerator(new Integer(logSpeedfield.getText()),
						this, cRcv.getInterfByName("WORD_TEST_OR_DATA"),"TESTORDATA");
				jLabel16.setEnabled(true);
				jLabel17.setEnabled(true);
				DataRelays.start("RAND_SND");
				DataRelays.start("RAND_REC");
				DataRelays.start("TESTORDATA");
			} catch (Exception e) {
				log.debug(e.getMessage());
			}
		} else { 
			DataRelays.dropDataReader("TESTORDATA");
			DataRelays.dropDataReader("RAND_REC");
			DataRelays.dropDataReader("RAND_SND");
			engageRndB.setText("Engage");
			jLabel16.setEnabled(false);
			jLabel17.setEnabled(false);
		}
		
	}
	
	protected void autoRead(JButton autobutn, String startString, String stopString) {
		TestHardware.incrementType=1;
		CCII_ACCESS_INTERF intr;
		if (autobutn.getText().equals(startString)) {
			autobutn.setText(stopString);
			ContextUtils cR = new ContextUtils(receiver);
			ContextUtils cRcv = new ContextUtils(cR.getChildByName("COMP_REC"));
			ContextUtils cS = new ContextUtils(sender);
			ContextUtils cSen = new ContextUtils(cS.getChildByName("COMP_SEND"));
			try {
				intr = cRcv.getInterfByName("WORD_TEST_DATA");
				new DataGenerator(new Integer(delayField.getText()),
						jTextField1, intr,"RAND_REC");
				intr = cSen.getInterfByName("WORD_TEST_DATA");
				new DataGenerator(new Integer(delayField.getText()),
						readStaticRegField, intr,"RAND_SND");
				new DataGenerator(new Integer(delayField.getText()),
						this, cRcv.getInterfByName("WORD_TEST_OR_DATA"),"TESTORDATAS");
				DataRelays.start("RAND_REC");
				DataRelays.start("RAND_SND");
				DataRelays.start("TESTORDATAS");
				
			} catch (Exception e) {
				log.debug(e.getMessage());
			}
		} else { 
			DataRelays.dropDataReader("TESTORDATAS");
			DataRelays.dropDataReader("RAND_REC");
			DataRelays.dropDataReader("RAND_SND");
			autobutn.setText(startString);
		}
		
	}
	
	private JButton getstaticWriteButton() {
		if(staticWriteButton == null) {
			staticWriteButton = wordDataTestS.getWriteButton();
			staticWriteButton.setBounds(387, 10, 75, 22);
			staticWriteButton.setVisible(true);
		}
		return staticWriteButton;
	}
	
	private JLabel getJLabel14() {
		if(jLabel14 == null) {
			jLabel14 = new JLabel();
			jLabel14.setIcon(ri);
			jLabel14.setEnabled(false);
			jLabel14.setBounds(147, 72, 22, 22);
			jLabel14.addVetoableChangeListener(new VetoableChangeListener() {
				public void vetoableChange(PropertyChangeEvent evt) {
					log.debug("jico1.vetoableChange, event="+evt);
					//TODO add your code for jico1.vetoableChange
				}
			});
		}
		return jLabel14;
	}
	
	private JLabel getJLabel15() {
		if(jLabel15 == null) {
			jLabel15 = new JLabel();
			jLabel15.setText("Data sample status: ");
			jLabel15.setBounds(27, 74, 100, 16);
		}
		return jLabel15;
	}
	
	private JButton getManualButton() {
		if(manualButton == null) {
			manualButton = new JButton();
			manualButton.setText("Manual");
			manualButton.setBounds(378, 73, 67, 20);
			manualButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { 
					log.info("Command: Static {} delay {}", new Object[] {manualButton.getText(), delayField.getText()});
					readManual();
					//TODO add your code for manualButton.actionPerformed
				}
			});
		}
		return manualButton;
	}
	
	private JButton getAutoButt() {
		if(autoButt == null) {
			autoButt = new JButton();
			autoButt.setText("Auto");
			autoButt.setBounds(111, 21, 67, 20);
			autoButt.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { 
					log.info("Command: Static {} delay {}", new Object[] {autoButt.getText(), delayField.getText()});
					autoRead(autoButt,"Auto","Stop");
				}
			});
		}
		return autoButt;
	}
	
	private JPanel getJPanel9() {
		if(jPanel9 == null) {
			jPanel9 = new JPanel();
			jPanel9.setBounds(197, 52, 181, 43);
			jPanel9.setBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED));
			jPanel9.setLayout(null);
			jPanel9.add(getDelayTxt());
			jPanel9.add(getDelayField());
			jPanel9.add(getAutoButt());
		}
		return jPanel9;
	}
	
	private JLabel getDelayTxt() {
		if(delayTxt == null) {
			delayTxt = new JLabel();
			delayTxt.setText("Delay in ms:");
			delayTxt.setBounds(5, 4, 58, 14);
		}
		return delayTxt;
	}
	
	private JTextField getDelayField() {
		if(delayField == null) {
			delayField = new JTextField();
			delayField.setText("600");
			delayField.setBounds(65, 3, 112, 17);
		}
		return delayField;
	}
	
	private JScrollPane getJScrollPane4() {
		if(jScrollPane4 == null) {
			jScrollPane4 = new JScrollPane();
			jScrollPane4.setBounds(16, 17, 445, 82);
			jScrollPane4.setViewportView(getLogPane1());
		}
		return jScrollPane4;
	}
	
	private JTextPane getLogPane1() {
		if(logPane1 == null) {
			logPane1 = new JTextPane();
			logPane1.setEditable(false);
			logPane1.setFont(new java.awt.Font("Tahoma",0,10));
		}
		return logPane1;
	}
	
	private JButton getJButtonSelect() {
		if(jButtonSelect == null) {
			jButtonSelect = new JButton();
			jButtonSelect.setText("s");
			jButtonSelect.setFont(new java.awt.Font("Tahoma",0,10));
			jButtonSelect.setToolTipText("Select all");
			jButtonSelect.setBounds(0, 84, 15, 14);
			jButtonSelect.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { 
					log.info("Command: Random {}", jButtonSelect.getToolTipText());
					logPane1.grabFocus();
					logPane1.selectAll();									
				}
			});
		}
		return jButtonSelect;
	}
	
	private void logln(String arg) {
		logPane1.selectAll();
		logPane1.setCaretPosition(logPane1.getSelectionEnd());
		logPane1.setEditable(true);
		logPane1.replaceSelection(arg+"\n");
		logPane1.setEditable(false);
	}
	private void log(String arg) {
		logPane1.selectAll();
		logPane1.setCaretPosition(logPane1.getSelectionEnd()-1);
		logPane1.setEditable(true);
		logPane1.replaceSelection(arg);
		logPane1.setEditable(false);
	}
	
	private JLabel getRandResTxt() {
		if(randResTxt == null) {
			randResTxt = new JLabel();
			randResTxt.setText("Test results:");
			randResTxt.setBounds(17, 1, 80, 14);
			randResTxt.setFont(new java.awt.Font("Tahoma",1,11));
		}
		return randResTxt;
	}
	
	private JButton getEngageRndB() {
		if(engageRndB == null) {
			engageRndB = new JButton();
			engageRndB.setText("Engage");
			engageRndB.setBounds(463, 80, 73, 18);
			engageRndB.setBackground(new java.awt.Color(128,0,255));
			engageRndB.setForeground(new java.awt.Color(0,0,128));
			engageRndB.setFont(new java.awt.Font("Tahoma",1,11));
			engageRndB.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { 
					log.info("Command: Random {} {}", new Object[] {evt.getActionCommand(), logSpeedfield.getText()} );
					engageRand();
				}
			});
		}
		return engageRndB;
	}
	
	private JLabel getLogIntervTxt() {
		if(logIntervTxt == null) {
			logIntervTxt = new JLabel();
			logIntervTxt.setText("Delay in ms:");
			logIntervTxt.setBounds(470, 17, 61, 15);
		}
		return logIntervTxt;
	}
	
	private JTextField getLogSpeedfield() {
		if(logSpeedfield == null) {
			logSpeedfield = new JTextField();
			logSpeedfield.setText("600");
			logSpeedfield.setBounds(471, 32, 55, 20);
		}
		return logSpeedfield;
	}

	private void readManual() {
		TestHardware.incrementType=0;
		ContextUtils cR = new ContextUtils(receiver);
		ContextUtils cRcv = new ContextUtils(cR.getChildByName("COMP_REC"));
		ContextUtils cS = new ContextUtils(sender);
		ContextUtils cSen = new ContextUtils(cS.getChildByName("COMP_SEND"));
		try {
			long tms = cSen.getInterfByName("WORD_TEST_DATA").readSimple();
			readStaticRegField.setText(""+tms);
			long tmr = cRcv.getInterfByName("WORD_TEST_DATA").readSimple();
			jTextField1.setText(""+tmr);
			if (tms==tmr) {
				jico1.setIcon(gi);
				jico1.setEnabled(true);
			}
			else {
				jico1.setIcon(ri);
				jico1.setEnabled(true);
			}
			long tmor =cRcv.getInterfByName("WORD_TEST_OR_DATA").readSimple();
			if (tmor!=0) {
				jLabel14.setIcon(ri);
				jLabel14.setEnabled(true);
			} else {
				jLabel14.setIcon(gi);
				jLabel14.setEnabled(true);				
			}
			
		} catch (Exception e) {
			log.error("", e);
		}
		
	}

	/* (non-Javadoc)
	 * @see cii_functions.IDataCommuniactor#writeData()
	 */
	@Override
	public synchronized void writeData(CIIdata data, String id) {
		if (id.equals("TESTORDATAS")) {
			jLabel14.setEnabled(true);
			if (data.GetValue()==0) jLabel14.setIcon(gi);
			else {
				jLabel14.setIcon(ri);
				logln(System.currentTimeMillis()+" ["+id+"]:"+data.GetBin0()+": "+data.GetValue());
			}
		}
		if (!id.equals("TESTORDATA")) 
			logln(System.currentTimeMillis()+" ["+id+"]:"+data.GetBin0()+": "+data.GetValue());
		else {
			log.debug(id+" "+data.GetBin0());
			if (data.GetValue()!=0) {jLabel17.setIcon(ri); log("\tERR");}
			else {
				jLabel17.setIcon(gi);
				log("\tOK");
			}
		}
	}
	
	private JLabel getJLabel16() {
		if(jLabel16 == null) {
			jLabel16 = new JLabel();
			jLabel16.setIcon(gi);
			jLabel16.setEnabled(false);
			jLabel16.setBounds(473, 53, 22, 22);
			jLabel16.setToolTipText("Data comparable");
			jLabel16.addVetoableChangeListener(new VetoableChangeListener() {
				public void vetoableChange(PropertyChangeEvent evt) {
					log.debug("jico1.vetoableChange, event="+evt);
					//TODO add your code for jico1.vetoableChange
				}
			});
		}
		return jLabel16;
	}
	
	private JLabel getJLabel17() {
		if(jLabel17 == null) {
			jLabel17 = new JLabel();
			jLabel17.setIcon(gi);
			jLabel17.setEnabled(false);
			jLabel17.setBounds(505, 53, 22, 22);
			jLabel17.setToolTipText("Data compatibile");
			jLabel17.addVetoableChangeListener(new VetoableChangeListener() {
				public void vetoableChange(PropertyChangeEvent evt) {
					log.debug("jico1.vetoableChange, event="+evt);
					//TODO add your code for jico1.vetoableChange
				}
			});
		}
		return jLabel17;
	}
	
	private JScrollPane getJScrollPane5() {
		if(jScrollPane5 == null) {
			jScrollPane5 = new JScrollPane();
			getJScrollPane5().getVerticalScrollBar().setValue(30);
			getJScrollPane5().getVerticalScrollBar().setUnitIncrement(5);
			jScrollPane5.setViewportView(getJPanel11());
		}
		return jScrollPane5;
	}
	
	private JPanel getJPanel11() {
		if(jPanel11 == null) {
			jPanel11 = new JPanel();
			jPanel11.setPreferredSize(new java.awt.Dimension(521, 172));
			jPanel11.setLayout(null);
			jPanel11.add(getTechSegPanel());
			jPanel11.add(getJPanel12());
			jPanel11.add(getJLabel26());
			jPanel11.add(getJLabel27());
			jPanel11.add(getJLabel28());
			jPanel11.add(getJLabel29());
			jPanel11.add(getJLabel30());
			jPanel11.add(getJLabel31());
			jPanel11.add(getJLabel32());
			jPanel11.add(getJLabel33());
			jPanel11.add(getJLabel34());
			jPanel11.add(getJLabel35());
		}
		return jPanel11;
	}
	
	private JButton getJButton8() {
		if(jButton8 == null) {
			jButton8 = new JButton();
			jButton8.setText("-");
			jButton8.setFont(new java.awt.Font("Tahoma",0,10));
			jButton8.setToolTipText("Clear all");
			jButton8.setBounds(0, 68, 15, 16);
			jButton8.setMargin(new java.awt.Insets(0, 1, 0, 0));
			jButton8.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { 
					log.info("Command: Random {}", jButton8.getToolTipText());
					logPane1.grabFocus();
					logPane1.setEditable(true);
					logPane1.setText("");
					logPane1.setEditable(false);
				}
			});
		}
		return jButton8;
	}
	
	private JButton getJButton7x() {
		if(jButton7 == null) {
			jButton7 = new JButton();
			jButton7.setText("H");
			jButton7.setBounds(0, 53, 15, 16);
			jButton7.setMargin(new java.awt.Insets(0,1,0,0));
			jButton7.setFont(new java.awt.Font("Tahoma",0,10));
			jButton7.setToolTipText("Print header");
			jButton7.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { 
					log.info("Command: Random {}", jButton7.getToolTipText());
					logln(" Timestamp  [    Name    ]: \t  Binary data\t   :"+" "+" Decimal " + "\t       < Sample status >");
				}
			});
		}
		return jButton7;
	}
	
	private JPanel getTechSegPanel() {
		if(techSegPanel == null) {
			techSegPanel = new JPanel();
			techSegPanel.setLayout(null);
			techSegPanel.setBounds(10, 1, 246, 58);
			techSegPanel.setBorder(BorderFactory.createTitledBorder("Technical segmentation:"));
			techSegPanel.add(getJLabel18());
			techSegPanel.add(getJLabel19());
			techSegPanel.add(getJLabel20());
			techSegPanel.add(getJLabel21());
		}
		return techSegPanel;
	}
	
	private JPanel getJPanel12() {
		if(jPanel12 == null) {
			jPanel12 = new JPanel();
			jPanel12.setBorder(BorderFactory.createTitledBorder("Logical segmentation:"));
			jPanel12.setLayout(null);
			jPanel12.setBounds(266, 1, 245, 58);
			jPanel12.add(getJLabel22());
			jPanel12.add(getJLabel23());
			jPanel12.add(getJLabel24());
			jPanel12.add(getJLabel25());
		}
		return jPanel12;
	}
	
	private JLabel getJLabel18() {
		if(jLabel18 == null) {
			jLabel18 = new JLabel();
			jLabel18.setText("Wire ammount: ");
			jLabel18.setBounds(28, 19, 76, 14);
		}
		return jLabel18;
	}
	
	private JLabel getJLabel19() {
		if(jLabel19 == null) {
			jLabel19 = new JLabel();
			jLabel19.setText("Wire data width: ");
			jLabel19.setBounds(28, 36, 83, 14);
		}
		return jLabel19;
	}
	
	private JLabel getJLabel20() {
		if(jLabel20 == null) {
			jLabel20 = new JLabel();
			jLabel20.setText("0");
			jLabel20.setBounds(132, 19, 96, 14);
		}
		return jLabel20;
	}
	
	private JLabel getJLabel21() {
		if(jLabel21 == null) {
			jLabel21 = new JLabel();
			jLabel21.setText("0");
			jLabel21.setBounds(132, 36, 96, 14);
		}
		return jLabel21;
	}
	
	private JLabel getJLabel22() {
		if(jLabel22 == null) {
			jLabel22 = new JLabel();
			jLabel22.setText("Partition width:");
			jLabel22.setBounds(29, 19, 73, 14);
		}
		return jLabel22;
	}
	
	private JLabel getJLabel23() {
		if(jLabel23 == null) {
			jLabel23 = new JLabel();
			jLabel23.setText("Partition number:");
			jLabel23.setBounds(29, 36, 83, 14);
		}
		return jLabel23;
	}
	
	private JLabel getJLabel24() {
		if(jLabel24 == null) {
			jLabel24 = new JLabel();
			jLabel24.setText("0");
			jLabel24.setBounds(135, 19, 92, 14);
		}
		return jLabel24;
	}
	
	private JLabel getJLabel25() {
		if(jLabel25 == null) {
			jLabel25 = new JLabel();
			jLabel25.setText("0");
			jLabel25.setBounds(135, 36, 92, 14);
		}
		return jLabel25;
	}
	
	private JLabel getJLabel26() {
		if(jLabel26 == null) {
			jLabel26 = new JLabel();
			jLabel26.setText("Data width:");
			jLabel26.setBounds(176, 63, 60, 14);
		}
		return jLabel26;
	}
	
	private JLabel getJLabel27() {
		if(jLabel27 == null) {
			jLabel27 = new JLabel();
			jLabel27.setText("0");
			jLabel27.setBounds(181, 77, 42, 14);
			jLabel27.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel27.setFont(new java.awt.Font("Tahoma",1,11));
		}
		return jLabel27;
	}
	
	private JLabel getJLabel28() {
		if(jLabel28 == null) {
			jLabel28 = new JLabel();
			jLabel28.setText("=");
			jLabel28.setBounds(243, 71, 10, 14);
		}
		return jLabel28;
	}
	
	private JLabel getJLabel29() {
		if(jLabel29 == null) {
			jLabel29 = new JLabel();
			jLabel29.setText("Data:");
			jLabel29.setBounds(271, 63, 27, 14);
		}
		return jLabel29;
	}
	
	private JLabel getJLabel30() {
		if(jLabel30 == null) {
			jLabel30 = new JLabel();
			jLabel30.setText("Analysis:");
			jLabel30.setBounds(339, 63, 47, 14);
		}
		return jLabel30;
	}
	
	private JLabel getJLabel31() {
		if(jLabel31 == null) {
			jLabel31 = new JLabel();
			jLabel31.setText("0");
			jLabel31.setBounds(269, 77, 29, 14);
			jLabel31.setFont(new java.awt.Font("Tahoma",1,11));
			jLabel31.setHorizontalAlignment(SwingConstants.CENTER);
		}
		return jLabel31;
	}
	
	private JLabel getJLabel32() {
		if(jLabel32 == null) {
			jLabel32 = new JLabel();
			jLabel32.setText("+");
			jLabel32.setBounds(315, 71, 10, 14);
		}
		return jLabel32;
	}
	
	private JLabel getJLabel33() {
		if(jLabel33 == null) {
			jLabel33 = new JLabel();
			jLabel33.setText("0");
			jLabel33.setBounds(337, 77, 43, 14);
			jLabel33.setHorizontalAlignment(SwingConstants.CENTER);
			jLabel33.setFont(new java.awt.Font("Tahoma",1,11));
		}
		return jLabel33;
	}
	
	private JLabel getJLabel34() {
		if(jLabel34 == null) {
			jLabel34 = new JLabel();
			jLabel34.setText("Clock multiplexing:");
			jLabel34.setBounds(39, 96, 88, 14);
		}
		return jLabel34;
	}
	
	private JLabel getJLabel35() {
		if(jLabel35 == null) {
			jLabel35 = new JLabel();
			jLabel35.setText("0");
			jLabel35.setBounds(142, 96, 55, 14);
		}
		return jLabel35;
	}
	
	private JLabel getJLabel36() {
		if(jLabel36 == null) {
			jLabel36 = new JLabel();
			jLabel36.setText("Delay bits:");
			jLabel36.setBounds(242, 43, 51, 14);
		}
		return jLabel36;
	}

	private JButton getSetupBut() {
		if(setupBut == null) {
			setupBut = new JButton();
			setupBut.setText("Setup");
			setupBut.setBounds(423, 3, 86, 20);
			setupBut.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					setUpInterfaces();
				}
			});
		}
		return setupBut;
	}
	
	private void loadConfig() {
		ContextUtils cSen = new ContextUtils(sender);
		ContextUtils cRcv = new ContextUtils(receiver);
		ContextUtils cMux = new ContextUtils(cSen.getChildByName("COMP_MUX"));
		ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_DEMUX"));
		XMLConfiguration xDmx = ContextUtils.getConfigFromCU(cDmx);
		
		String path = xDmx.getString("BITS_MUX_CLK_INV");
		log.debug("path load: " + path);
		if (path!=null) {
			try {
			XMLConfiguration comp = new XMLConfiguration(new File(path));
			if (comp.getLong("BITS_MUX_CLK_INV")==1) {
			risinEdgeRB.setSelected(true);
			} else 
				buttonGroup1.clearSelection();
			} catch (Exception e) {
				log.error("", e);
			}
			
		}
	}

	private void setUpInterfaces() {

		ContextUtils cSen = new ContextUtils(sender);
		ContextUtils cRcv = new ContextUtils(receiver);
		ContextUtils cMux = new ContextUtils(cSen.getChildByName("COMP_MUX"));
		ContextUtils cDmx = new ContextUtils(cRcv.getChildByName("COMP_DEMUX"));
		log.debug("Konfig:");
		try {
			if (cMux.getInterfByName("BITS_CLK_INV").readSimple()!=
				cDmx.getInterfByName("BITS_CLK_INV").readSimple()) {
				log.debug("Error BITS_CLK_INV!");
				return;
			}
			if (cMux.getInterfByName("BITS_CLK_INV").readSimple()==0) {
				risinEdgeRB.setSelected(false);
				fallEdgeRB.setSelected(true);
			} else {
				risinEdgeRB.setSelected(true);
				fallEdgeRB.setSelected(false);
			}
			if (cDmx.getInterfByName("BITS_MUX_CLK90").readSimple()==0) {
				phasedRB.setSelected(false);
				notPhasedRB.setSelected(true);
			} else {
				phasedRB.setSelected(true);
				notPhasedRB.setSelected(false);
			}
			if (cDmx.getInterfByName("BITS_MUX_REG_ADD").readSimple()==0) {
				jCheckBox1.setSelected(false);
			} else {
				jCheckBox1.setSelected(true);
			}
			ww.setText(""+cDmx.getInterfByName("BITS_DATA_DELAY").readSimple());
			if (cSen.getInterfByName("BITS_CHECK_ENA").readSimple()!=
				cRcv.getInterfByName("BITS_CHECK_ENA").readSimple()){
				log.debug("Error BITS_CHECK_ENA!");
				return;
			}
			if (cSen.getInterfByName("BITS_CHECK_ENA").readSimple()==0) {
				xorCSCB.setSelected(false);
			} else {
				xorCSCB.setSelected(true);
			}
			if (cSen.getInterfByName("BITS_CHECK_DATA_ENA").readSimple()!=
				cRcv.getInterfByName("BITS_CHECK_DATA_ENA").readSimple()){
				log.debug("Error BITS_CHECK_DATA_ENA!");
				return;
			}
			if (cSen.getInterfByName("BITS_CHECK_DATA_ENA").readSimple()==0) {
				jCheckBox3.setSelected(false);
			} else {
				jCheckBox3.setSelected(true);
			}
			if (cMux.getInterfByName("BITS_CLK_INV").readSimple()!=
				cDmx.getInterfByName("BITS_CLK_INV").readSimple()){
				log.debug("Error BITS_CLK_INV!");
				return;
			}
			if (cMux.getInterfByName("BITS_CLK_INV").readSimple()==0) {
				invClkBox.setSelected(false);
			} else {
				invClkBox.setSelected(true);
			}if (cMux.getInterfByName("BITS_SWAP_ENA").readSimple()!=
				cDmx.getInterfByName("BITS_SWAP_ENA").readSimple()){
				log.debug("Error BITS_SWAP_ENA!");
				return;
			}
			if (cMux.getInterfByName("BITS_SWAP_ENA").readSimple()==0) {
				jCheckBox2.setSelected(false);
			} else {
				jCheckBox2.setSelected(true);
			}
//			log.debug(cDmx.getInterfByName("BITS_MUX_CLK_INV").readSimple());
		} catch (Exception e) {
			log.error("", e);
		}
	
	}
	
	private JButton getLoadCfgB() {
		if(loadCfgB == null) {
			loadCfgB = new JButton();
			loadCfgB.setText("Load Cfg");
			loadCfgB.setBounds(330, 3, 86, 20);
			loadCfgB.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent evt) { log.info("Command: {}", evt.getActionCommand());
					loadConfig();
				}
			});
		}
		return loadCfgB;
	}
}
